﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Animation;

namespace G.Controls
{
    public class TostNotification : Window
    {
        public static void Show(string content, int level = 0)
        {
            TostNotification t = new TostNotification();
            t.content = content;
            t.IsOpen = true;
        }
        private string content;
        internal TostNotification()
        {
            this.DefaultStyleKey = typeof(TostNotification);
            timer = new Windows.UI.Xaml.DispatcherTimer() { Interval = TimeSpan.FromSeconds(4) };
            timer.Tick += timer_Tick;
        }

        void timer_Tick(object sender, object e)
        {
            timer.Stop();
            this.IsOpen = false;
        }
        Windows.UI.Xaml.DispatcherTimer timer;
        protected override void OnOpening()
        {
            base.OnOpening();
            this.Width = Windows.UI.Xaml.Window.Current.Bounds.Width;
            this.Content = content;
            timer.Start();
        }

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.Transitions = new TransitionCollection();
            EntranceThemeTransition transition = new EntranceThemeTransition();
            transition.FromHorizontalOffset = 100;
            this.Transitions.Add(transition);
        }
    }
}
